package lesson02;

/**
 * 给线程起一个名字
 *
 * @author wileda
 * @date 2023/01/04  9:21
 */
public class Demo01 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
           while (true){
               System.out.println("大圣归来, " + Thread.currentThread().getName());
               //类名
               String className = Demo01.class.toString();
               //方法名
               String mName = Thread.currentThread().getStackTrace()[1].getMethodName();
               //线程名
               String tName = Thread.currentThread().getName();
               System.out.println("当前线程：" +className + "." + mName + "." + tName);
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        },"俺老孙有名字l");
        thread.start();
    }
}
